Skip to main content

All Questions

Tagged with
2votes
2answers
381views

Unit testing for non-stateless units - how?

Firstly let me say I have never written a unit test in my life. I am trying to get the hang of PHPUnit, and so far it's working pretty well for me so far as "stateless" functions (that ...
user avatar
3votes
2answers
534views

Is it okay to use Dependency injection only because of unit testing?

I have a class that has dependencies that I know are not going to change. class ConversationFinder { public function __construct( protected Conversation $conversationDbFinder = new ...
Ghassan Barghouti's user avatar
3votes
1answer
659views

Testing Queries Themselves with Test data is a Unit test or an Integration test?

In a php project that I maintain I have a database structure without migrations, hence no way to reproduce it or make on the fly a test database. And the queries used to be performed on them are ...
Dimitrios Desyllas's user avatar
-1votes
1answer
139views

How to test and what kinds of test to write for Request Handlers that use Repository layer?

Consider class below: class FillTestBySerialHandler { /** * * @var FillTestBySerialRepository */ private $fillTestBySerialRepository; function __construct(...
Dennis's user avatar
  • 8,257
0votes
1answer
661views

Unit tests involving library functions and objects

I am making a project using the Laravel framework. I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. ...
lightning_missile's user avatar
0votes
1answer
5kviews

How to pass a mock object into a class for unit tests

There seem to be many ways to pass a mocked object into a class for unit testing and I am unsure which is the proper approach to take for my PHP application. If I was using Dependency Injection then ...
nevada_scout's user avatar
1vote
2answers
1kviews

TDD workflow with integration testing

I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that ...
Steve Chamaillard's user avatar
2votes
4answers
2kviews

How to write a unit test for a repository method that returns some data, where data can change over time?

I have some code that reads five numbers from a database: class Repository extends DatabaseRepository { function getCoefficients(string $model) { return $this->getDatabaseLink()-&...
Dennis's user avatar
  • 8,257
-1votes
1answer
162views

How to approach writing a 'test' for a series of input->output sets, that will later be used to verify correctness of a new system?

I have a system ("an engine", which is a piece of code) that takes in several parameters returns some output. The input parameters are several distinct and constrained sets. I can enumerate all of ...
Dennis's user avatar
  • 8,257
1vote
1answer
128views

Importance of PHP unit tests regarding to basic classes

For 3 months, I've been working on a Web Project using PHP to create a platform to handle remote lights and sensors. I'm currently working almost alone on it, but we will be 2 on it in the next months....
Victor Gerfaud's user avatar
-2votes
2answers
1kviews

Writing unit test cases are taking time, any advice?

I am new to unit testing. Started working on unit test using PHPUnit. But it seems to be taking too much time. If consider I take 3 hours to write a Class, its taking my 7 hours to write test case for ...
Pratik Joshi's user avatar
5votes
3answers
538views

Necessity of TDD in web application development

There are only two members in our development team and we started to work on a medium scale web application (Laravel). My question is about testing especially TDD, Do we really start to follow TDD ...
Jabaa's user avatar
6votes
2answers
3kviews

Unit Testing: Method per test versus data provider

I'm having a bit of a philosophical argument with one of my colleagues regarding the "right" way to do unit tests (in this case with PHPUnit). I'm of the opinion that you should write one test method ...
GordonM's user avatar
  • 6,515
4votes
0answers
185views

unit testing a mocked class [duplicate]

I'm currently writing unit tests for my PHP code. I've read that unit tests should not interract with external elements such as network and filesystem. In my code i have a curl wrapper class to ...
ᴄʀᴏᴢᴇᴛ's user avatar
1vote
1answer
804views

How would you test this class and is it integration test or unit test?

Consider this example class which in encrypting some data and sending it to some other service. Consider the test for redirect method. This is how you consume the class: <?php $safeLink = new ...
madpoet's user avatar

153050per page
close